Skip to content

Fix concurrency bug in ScopedAtomicFactory#778

Merged
bitfaster merged 3 commits intomainfrom
users/alexpeck/scopedatomconc
Apr 19, 2026
Merged

Fix concurrency bug in ScopedAtomicFactory#778
bitfaster merged 3 commits intomainfrom
users/alexpeck/scopedatomconc

Conversation

@bitfaster
Copy link
Copy Markdown
Owner

@bitfaster bitfaster commented Apr 19, 2026

This should be a volatile read, see equivalent code for ScopedAsyncAtomicFactory:

var init = Volatile.Read(ref initializer);

Issue was exposed via new soak tests in #771. This shows there is also a test gap.

Without the volatile read, the JIT will optimize away the copy. Fixed the same issue in the dispose code path.

@coveralls
Copy link
Copy Markdown

coveralls commented Apr 19, 2026

Coverage Status

coverage: 99.021% (-0.09%) from 99.11% — users/alexpeck/scopedatomconc into main

@bitfaster bitfaster merged commit 842e91e into main Apr 19, 2026
27 of 30 checks passed
@bitfaster bitfaster deleted the users/alexpeck/scopedatomconc branch April 19, 2026 04:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants